/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */
#pragma once

#include <queue>
#include <list>
#include <threads/Lock.h>
#include <NoCopy.h>
#include <HardwareManager.h>
#include <Atom.h>
#include "Event.h"

namespace liba {
namespace input {

namespace hard { class Hardware; }
namespace hard { class ForceEffect; }
class Listener;

class Manager :
	public HardwareManagerNamed<hard::Hardware, std::string>
{
	typedef std::queue<Event> Queue;
	typedef std::list<Listener *> Listeners;
public:
	class Creator : virtual public HardwareManagerNamed<hard::Hardware, std::string>::Creator
	{
	public:
		Creator();
		~Creator();
	};
	enum AxisType { NONE, BUTTON, AXIS, INF_AXIS, POV };
	static const Atom strange_type_name;
	static const Atom mouse_type_name;
	static const Atom joystick_type_name;
	static const Atom keyboard_type_name;

	static void add_listener( Listener * listener );
	static void remove_listener( Listener * listener );

	static AxisType get_axis_type( const std::string & hardware_name, const std::string & axis_name );
	static double get_axis_position( const std::string & hardware_name, const std::string & axis_name );
	static Atom get_hardware_type(const std::string & hardware_name);
	
	static void add_event( const Event & event );
	static void LifeCycle();

	static hard::ForceEffect * create_force_effect( const std::string & hardware_name, const filesystem::String & effect_name );
private:
	static Queue * queue;
	static Listeners * listeners;
	static threads::Mutex mutex;
};

} // namespace input
} // namesapce liba
using namespace liba;
